package cn.itrip.common;

import org.springframework.context.annotation.Configuration;

import java.io.FileWriter;
import java.io.IOException;

/**
 * @Author:小伟
 * @Description:
 * @Date:2020-03-18 15:02
 **/
@Configuration
public class AlipayConfig {
    /**
     * 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号,开发时使用沙箱提供的APPID，生产环境改成自己的APPID
     */
    public static String APP_ID = "2016101800712694";

    /**
     * 商户私钥，您的PKCS8格式RSA2私钥
     */
    public static String APP_PRIVATE_KEY = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCaGnrQR1Hwr6SQSqNFH01IiEAVPHxvA3SjVpQErVubKMfWW0GodXWnd1iTKi3n4eXPUGRaW3hC91cVDUw6U48siatXD8EKJ4Y/39OKzg8wky95dfHm6f368LwpiIUaWbf3ZlJn2cdBrB2OreFUn0v8J8PO2RxSWL6heay4yA0THrRHWxLS3f7pFPe1tVmjdxWP+4kFY+0CsNivQ4fEw18WSbdSt2kJ8nNgtKZHnVR6y/DM2VkAXA87KsP85Z8dryIGue/CS63qBMQzawZZ+yQeyj2HgyUn46uL6jzOCz8ExxIWVhfwuFPSwvR0Xvgai+BD5StYS20vc4fmbdopC8VVAgMBAAECggEAZRzEwo5ZRFxq1MY0VLFSKypDKevzFYAl8tpm6p64wZjDbnGYJilT1lrngkAluMUu3ZU5E1R7Fy1lNQnxnz+ebLGz+775gWknnBeHnMbRjqS0fLSX0VRs8k8slu/drcl6fNjlbwCkzgFZr3mFpNmUqNGKl9k6zQkvo5HLc77HXWg+NWWAny0tB/Iz8hE0nxYy3oVNJGan2PRkuD+U9APRssBf8cI3tTQKoCqV2347luy/l+7pMQnNg1/uaHavTDvRPIaQnmSR/JvTCBCoVhimhZlUiZshX3+vbyQivRp1Skoom20Z/sOf1iSDPUC2xldogfTaOzBIJzS4GBkwo/pJLQKBgQDOpM11H8jdcSIoVQPrfRivkxx8zvmza6KQEk2qWjKPLBq6eBKbaPB7ivsQdjNqEPWDcrRCjlh0rPu28179KpCoLs5XUcdC9bT059OtwabAPC0mMefr1NUxZdRxnz4U3U3zxpcmAKYtJk9L6gjJwOJxgQKGX4soT8BFEHFAfDgVgwKBgQC+6Rupr3/0121J+rkkR2q3VH9kK0uX72PiAl+55qcXYBniiJTyWkcFo7Kblhsd3IDI/nLIuws6CF4hnZdTxVG5vRuK+q/7bd5OKW1A5W564zEmcDzW8pH8rtYNSAxkkekPUs07CKeQjivE9ouF3TlNXeP7mUAUWF0OBlmcbK+aRwKBgQCeHIk8QequTR8mnw4VxCz8QmK8uJ1khEnpVKfqXYNr+wIkhTUvhlbjII9DpD1ovbstLbnxZvsVozoiXQrkSQpQNSgate7yNBCWhz93JsIROroNDIh48OuDFXg8y+xziHVZvizunfaIe1SXMGYzAQwCbwTgjgBrAsKJ1a/h+GntQwKBgCaYN6hxO1wDJSv8jOtBqNhRM8PLYOfhVH7/XdzWPVdjbTg3xmzMRWllc5kyml7KEhsQHaJo9dcQk/8Vvd8ImAIFsgjBr0wUJQoGI/knqNMdFPWhYRtPRKYhrlJXC3JVcRlQ8v6JPF7j7wNNmF1CoO/8GDfn/mVei8lnDTyrWEDHAoGBAIFaKp5HsyUlu+GZzO9coc/MaHItElrYq0urDiLYg0vjwoWTOqIYkAcPys7oWJ63BpmLSRa2QnViISzmZH3ghimRl7mTgYJoq9r/r2d9EeXC3rr2bD903pKDa5+1qaNl2NIGuXa9PEH7T5uRJRK4x/jCHF0jcV1MpD1letcn67vC";

    /**
     * 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
     */
    public static String ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnZ2ip7Ryh26SjgzZ15bHSKvkx4wmTYkq+77sb0Ku4Gt746zded5kBODVNNsZxifB9ecQ6XC9bQde/jV1lppo6oS3D1mcf3cN+HLqzCSu3s8pZi1C9Y809Je6LMRq95FYCSCvyTHD9+l3vO4JLOR/LfzjPWZHhV+o/spK6zp0ZaqSfTTDdWYr+Qfh9lomf6aDHMH5kPH0BFRvn9NpO6g9DDy3GgkDNNeZiA3LB/VRZ0/zypka24CpoMFeBjJhdrfiFyBlNfXN5PLLyOynw20DFhWgwNKxd+S9OehxzoeXpHOFXIV3jXGWrPW/7j/h688xb8lenCjMT/2zJHWK4uxNtwIDAQAB";

    /**
     * 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
     */
    public static String notify_url = "http://8feyhm.natappfree.cc/trade/api/notify_url";

    /**
     * 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问(其实就是支付成功后返回的页面)
     */
    public static String return_url = "http://8feyhm.natappfree.cc/trade/api/return_url";

    // 签名方式
    public static String sign_type = "RSA2";

    // 字符编码格式
    public static String CHARSET = "utf-8";

    // 支付宝网关，这是沙箱的网关
    public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";

    // 支付宝网关
    public static String log_path = "C:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
